package com.zkdcloud.controller.mobile;

import com.xdja.interceptor.bean.ResultBean;
import com.zkdcloud.domain.FeedBack;
import com.zkdcloud.domain.PaymentPlatform;
import com.zkdcloud.dto.TerminalSetting;
import com.zkdcloud.repository.FeedbackDao;
import com.zkdcloud.service.FeedBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 公共controller
 *
 * @author zk123
 * @version 2018/5/16
 */
@RestController
@RequestMapping(value = "/api")
public class MobileCommonController {

    @Autowired
    private FeedBackService feedBackService;

    @RequestMapping(value = "/settings",method = RequestMethod.GET)
    public Object getSetting(){
        TerminalSetting result = new TerminalSetting();

        //remarks
        List<String> remarks = Arrays.asList("多放辣","三双筷子");
        result.setCommon_remarks(remarks);

        //payment
        List<PaymentPlatform> paymentPlatforms = new ArrayList<>();

        PaymentPlatform paymentPlatform = new PaymentPlatform();
        paymentPlatform.setId(String.valueOf(1));
        paymentPlatform.setCreateTime(System.currentTimeMillis());
        paymentPlatform.setIcon("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1470359682,3207323946&fm=27&gp=0.jpg");
        paymentPlatform.setName("支付宝");
        paymentPlatforms.add(paymentPlatform);
        result.setPayment_platforms(paymentPlatforms);

        PaymentPlatform paymentPlatform1 = new PaymentPlatform();
        paymentPlatform1.setId(String.valueOf(1));
        paymentPlatform1.setCreateTime(System.currentTimeMillis());
        paymentPlatform1.setIcon("http://img4.imgtn.bdimg.com/it/u=877456182,1772571574&fm=27&gp=0.jpg");
        paymentPlatform1.setName("微信");
        paymentPlatforms.add(paymentPlatform1);
        result.setPayment_platforms(paymentPlatforms);

        return result;
    }

    /**
     * 添加反馈接口
     *
     * @param feedBack
     * @return
     */
    @RequestMapping(value = "/feedbacks",method = RequestMethod.POST)
    public Object addFeedBack(@RequestBody FeedBack feedBack){
        feedBackService.add(feedBack);
        return feedBack;
    }
}
